// 配置
package config

import (
	"strings"

	"gitee.com/copylian/lian-go.git/bootstrap"
)

// GetConfigByName 获取配置数据，filePath：app.db.dbName
func GetConfigByName(filePath string) interface{} {
	if filePath == "" {
		return ""
	}

	// 路径
	paths := strings.Split(filePath, ".")

	// 获取配置
	configData := bootstrap.GetConfigByName(paths[0])
	if len(paths) == 1 {
		return configData
	}
	if len(paths) == 2 {
		return configData[paths[1]]
	}
	if v, ok := configData[paths[1]].(map[string]interface{}); ok {
		return v[paths[2]]
	}
	return nil
}
